home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / El temporizador y la hora / CloseInFive / CloseInFive.cs next >
Encoding:
Text File  |  2002-07-15  |  818 b   |  33 lines

  1. //------------------------------------------
  2. // CloseInFive.cs ⌐ 2001 by Charles Petzold
  3. //------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class CloseInFive: Form
  9. {
  10.      public static void Main()
  11.      {
  12.           Application.Run(new CloseInFive());
  13.      }
  14.      public CloseInFive()
  15.      {
  16.           Text = "Acabarß en cinco minutos";
  17.  
  18.           Timer timer    = new Timer();
  19.           timer.Interval = 5 * 60 * 1000;
  20.           timer.Tick    += new EventHandler(TimerOnTick);
  21.           timer.Enabled  = true;
  22.      }
  23.      void TimerOnTick(object obj, EventArgs ea)
  24.      {
  25.           Timer timer = (Timer) obj;
  26.  
  27.           timer.Stop();
  28.           timer.Tick -= new EventHandler(TimerOnTick);
  29.  
  30.           Close();          
  31.      }
  32. }
  33.